package com.icangya.DAO.impl;

import com.icangya.DAO.IRwUserBankDAO;
import com.icangya.domain.RwUserBank;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class RwUserBankDAOImpl extends  BaseDAO<RwUserBank> implements IRwUserBankDAO {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public List<RwUserBank> selectAllNeedPayInfo() {

        String hql=" FROM RwUserBank bugcar ";

        List<RwUserBank> list=(List<RwUserBank>) getHibernateTemplate().find(hql);

        if(list.size()>0){
            return list;
        }
        return null;

    }

    @Override
    public List<RwUserBank> getUserBanksByUserid(long userid) {
        String hql=" FROM RwUserBank bugcar where bugcar.userid = ?";

        List<RwUserBank> list=(List<RwUserBank>) getHibernateTemplate().find(hql,userid);

        if(list.size()>0){
            return list;
        }
        return null;
    }

    @Override
    public List<RwUserBank> findBankCarByUserId(long id) {
        String hql="FROM RwUserBank er where er.userid='"+id+"' order by er.createTime desc";
        List<RwUserBank> rwUserBanks = (List<RwUserBank>)this.getHibernateTemplate().find(hql);
        return rwUserBanks;
    }

}
